﻿using System;
using System.Drawing.Imaging;
using System.IO;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Media.Media3D;
using CaptureImageTool;
using System.Speech.Synthesis;
using System.Windows.Documents;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Threading;
using System.Windows.Media.Animation;
using Rabbit.Controls;
using System.Diagnostics;
using testProject.ViewModel;
namespace testProject
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        MainPageViewModel viewModel = new MainPageViewModel();
        public MainWindow()
        {
            InitializeComponent();
            this.Loaded += new RoutedEventHandler(MainWindow_Loaded);
         }

        void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            this.DataContext = viewModel;
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {

        }

        private void textButton_Click(object sender, RoutedEventArgs e)
        {
            //TextRange range = new TextRange(rtbTest.Document.ContentEnd, rtbTest.Document.ContentEnd);
            //range.Text = DateTime.Now.ToLongTimeString();
            //range.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.Gray);

            //range = new TextRange(rtbTest.Document.ContentEnd, rtbTest.Document.ContentEnd);
            //range.Text = Environment.NewLine + "good";
            //range.ClearAllProperties();

            //append colored text
            string userInfo = string.Format("{0}\t{1}", "韩现龙", DateTime.Now.ToLongDateString());
            TextRange range = new TextRange(rtbTest.Document.ContentEnd, rtbTest.Document.ContentEnd);
            range.Text = userInfo;
            range.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.Gray);

            //append normal text
            range = new TextRange(rtbTest.Document.ContentEnd, rtbTest.Document.ContentEnd);
            range.Text += Environment.NewLine;
            range.Text += "Cool";
            range.Text += Environment.NewLine;
            range.Text += Environment.NewLine;
            //rtbTest.AppendText(Environment.NewLine);
            //rtbTest.AppendText("Cool");
            //rtbTest.AppendText(Environment.NewLine);
            //rtbTest.AppendText(Environment.NewLine);
            range.ClearAllProperties();

            rtbTest.ScrollToEnd();
        }

        private void coloredTextButton_Click(object sender, RoutedEventArgs e)
        {
            TextRange range = new TextRange(rtbTest.Document.ContentEnd, rtbTest.Document.ContentEnd);
            range.Text = "me";
            range.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.Gray);
        }
 
    } 
}
